#include "mainWindow.h"
#include <QString>
#include "translation.h"
#include "lyrWindow.h"
#pragma execution_character_set("utf-8")

mainWindow::mainWindow(QWidget* parent) : QMainWindow(parent)
{
    QWidget* centralWidget = new QWidget(this);
    setCentralWidget(centralWidget);

    background = new QPixmap("C:/Users/Huang/source/repos/translation/fengmian3.png");
    imageLabel = new QLabel(centralWidget);
    QPixmap scaledBackground = background->scaled(300, 200, Qt::KeepAspectRatio, Qt::SmoothTransformation);
    imageLabel->setPixmap(scaledBackground);
    

    layout = new QGridLayout(centralWidget);

    layout->addWidget(imageLabel, 0, 0, 1, 2);

    title = new QLabel("NLP ToolKit", centralWidget);
    title->setStyleSheet("font-size: 18px; font-weight: bold; margin: 10px 0;");
    layout->addWidget(title, 0, 0, 1, 2, Qt::AlignHCenter);

    translationButton = new QPushButton("Translation", centralWidget);
    lyricsButton = new QPushButton("Lyrics", centralWidget);

    lyricsButton->setStyleSheet("QPushButton {min-height: 50px;}");
    translationButton->setStyleSheet("QPushButton {min-height: 50px;}");

    layout->setColumnStretch(0, 1);
    layout->setColumnStretch(1, 1);

    layout->addWidget(lyricsButton, 1, 0);
    layout->addWidget(translationButton, 1, 1);

    resize(300, 200);

    connect(lyricsButton, &QPushButton::clicked, this, &mainWindow::toLyrics);
    connect(translationButton, &QPushButton::clicked, this, &mainWindow::toTranslation);
}

mainWindow::~mainWindow()
{
}

void mainWindow::toLyrics()
{
    lyrW = new lyrWindow(this);
    lyrW->show();
}

void mainWindow::toTranslation()
{
    transW = new translation(this);
    transW->show();
}